package com.sss.hloster0505;

public class Student implements Comparable {//集合内元素实现Comparable接口
	int stuNum = -1;
	String stuName = "";

	public Student(String stuName, int stuNum) {
		super();
		this.stuName = stuName;
		this.stuNum = stuNum;

	}

//实现Comparable 接口的compareTo(Object o)方法
	public int compareTo(Object o) {
		Student input = (Student) o;
		int res = stuNum < input.stuNum ? 1 : (stuNum == input.stuNum ? 0 : -1);
		if (res == 0) {
         res = stuName.compareTo(input.stuName);
		}
		return res;
	}

	public String toString() {
		return "学号为：  " + stuNum + "的学生，姓名为：   " + stuName;
	}

}
